﻿using System.Collections.Generic;

namespace Common.Extension
{
    public static class HashSetMethodExtension
    {
        /// <summary>
        /// 向hashSet中批量添加元素
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="hashSet"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static HashSet<T> AddRange<T>(this HashSet<T> hashSet, IEnumerable<T> values)
        {
            if (values == null)
            {
                return hashSet;
            }

            foreach (var value in values)
            {
                hashSet.Add(value);
            }
            return hashSet;
        }
    }
}
